package com.javasm.adminapi.module.priceadjust.controller;

import com.github.pagehelper.PageInfo;
import com.javasm.adminapi.common.R;
import com.javasm.adminapi.module.priceadjust.dto.SearchDTO;
import com.javasm.adminapi.module.priceadjust.entity.GgPriceAdjust;
import com.javasm.adminapi.module.priceadjust.service.GgPriceAdjustService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.ref.PhantomReference;
import java.util.Arrays;
import java.util.List;

/**
 * @className: PriceAdjustController
 * @description:
 * @author: lrg
 * @date: 2025/10/16 20:53
 * @version: 0.1
 * @since: jdk17
 */
@RestController
@RequestMapping("/priceAdjust")
public class PriceAdjustController {

    @Resource
    GgPriceAdjustService ggPriceAdjustService;
    @GetMapping("/list")
    public R listByCondition(SearchDTO searchDTO){
        PageInfo<GgPriceAdjust> list =ggPriceAdjustService.listByCondition(searchDTO);

        return R.ok(list);
    }

    @PostMapping("/save/update")
    public R saveOrUpdate(GgPriceAdjust priceAdjust){
        ggPriceAdjustService.saveOrUpdateWithTime(priceAdjust);
        return R.ok();
    }

    @PostMapping("/del/{ids}")
    public R delByBatch(@PathVariable ("ids") Integer[] ids){

        //批量或单独删除
        ggPriceAdjustService.removeBatchByIds(Arrays.asList(ids));
        return R.ok();
    }
}
